import os


def input_params():
    file_path = input("请输入文件路径：")
    file_start_name = input("请输入文件起始名称（例如00000001.jpg）：")
    return file_path, file_start_name


def file_name_handle():
    file_path, file_start_name = input_params()
    if '.' in file_start_name:
        start_index, ext = os.path.splitext(file_start_name)
        if os.path.exists(file_path):
            files = os.listdir(file_path)
            max_length = len(start_index)
            index = int(start_index)
            files = list(filter(lambda x: x.endswith(ext), files))
            for file in files:
                new_file = os.path.join(file_path, str(index).zfill(max_length) + ext)
                os.rename(os.path.join(file_path, file), new_file)
                print(f"newFileName:{new_file}")
                index += 1

    file_name_handle()


if __name__ == "__main__":
    file_name_handle()
